﻿var bunny;
var animhandle = null;

    
var app = new PIXI.Application(800, 600, {backgroundColor : 0x1099bb,forceCanvas:false,fps:100});
document.body.appendChild(app.view);

class aac{
    constructor(){
    }
    update(delta){
        bunny.rotation += Math.PI * delta;
        if(app.app_time>3.0){
            animhandle.stop();
        }
    }
}

    var style = new PIXI.TextStyle({
      fontFamily: 'Arial',
      fontSize: 36,
      fontStyle: 'italic',
      fontWeight: 'bold',
      fill: '#ffffff',//['#ffffff', '#00ff99'], // gradient
      stroke: '#4a1850',
      strokeThickness: 5,
      dropShadow: true,
      dropShadowColor: '#000000',
      dropShadowBlur: 4,
      dropShadowAngle: Math.PI / 6,
      dropShadowDistance: 6,
      wordWrap: true,
      wordWrapWidth: 440
    });
    
function addmore(){
    for(var i = 0;i < 20000;i++){
      var c = PIXI.Sprite.from_image('bunny');
      c.x = Math.random()*app.screen.width;
      c.y = Math.random()*app.screen.height;
      app.stage.add_child(c);
    }
}

PIXI.loader.add('bunny','bunny.png').load(()=>{
    
    addmore();
    
// create a new Sprite from an image path
bunny = PIXI.Sprite.from_image('bunny.png')

// center the sprite's anchor point
bunny.anchor.set(0.5);

// move the sprite to the center of the screen
bunny.x = app.screen.width / 2;
bunny.y = app.screen.height / 2;

app.stage.add_child(bunny);

var abc = new aac();
// Listen for animate update
animhandle = PIXI.ticker.run(abc.update.bind(abc));

var txt = new PIXI.Text('',style);
app.stage.add_child(txt);

PIXI.ticker.run(()=>{
    txt.text = app.fps.toFixed(3)+','+app.app_time.toFixed(3);
});
});